package com.ctshk.task.worker.processors;

import com.ctshk.common.dto.Result;
import com.ctshk.rpc.user.service.IUserStarVipService;
import com.github.kfcfans.powerjob.worker.core.processor.ProcessResult;
import com.github.kfcfans.powerjob.worker.core.processor.TaskContext;
import com.github.kfcfans.powerjob.worker.core.processor.sdk.BasicProcessor;
import com.github.kfcfans.powerjob.worker.log.OmsLogger;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;

/**
 * <p>
 *  增加星赏会会员积分并重新定级
 * </p>
 *
 * @author 李新科
 * @date 2021/6/24 19:33
 */
@Slf4j
@Component
public class AddIntegralProcessor implements BasicProcessor {

    @DubboReference
    private IUserStarVipService userStarVipService;

    @Override
    public ProcessResult process(TaskContext context) throws Exception {
        OmsLogger omsLogger = context.getOmsLogger();
        String jobParams = context.getJobParams();
        omsLogger.info("星赏会更新积分操作开始");
        Result result = userStarVipService.addPoints(jobParams);
        omsLogger.info("星赏会更新积分操作结束");
        boolean success = result.isSuccess();
        omsLogger.info("AddIntegralProcessor finished process,success: .", success);

        return new ProcessResult(success, context + ": " + success);
    }
}
